function BreadCrumb() {
  this.innerBorder = null;
  this.init();
}

BreadCrumb.prototype.init = function() {
  //   SYSML模块定义图
  //   DIAGRAM_SYSML_BLOCKDEFINITION
  //   SYSML内部模块图
  //   DIAGRAM_SYSML_INTERNALMODULE
  //   SYSML包图
  //   DIAGRAM_SYSML_PACKAGE
  //   SYSML参数图
  //   DIAGRAM_SYSML_PARAMETRIC
  //   SYSML活动图
  //   DIAGRAM_SYSML_ACTIVITY
  //   SYSML序列图
  //   DIAGRAM_SYSML_SEQUENCE
  //   SYSML状态机图
  //   DIAGRAM_SYSML_STATEMACHINE
  //   SYSML用例图
  //   DIAGRAM_SYSML_USECASE
  //   SYSML需求图
  //   DIAGRAM_SYSML_REQUIREMENT
};

BreadCrumb.prototype.getTextWidt = function(tag, text, fontSize) {
  const span = document.createElement(tag);
  span.innerText = text;
  span.style.fontSize = `${fontSize}px`;
  span.style.position = 'absolute';
  document.body.appendChild(span);
  const width = span.offsetWidth;
  document.body.removeChild(span);
  console.log(width);
  return width;
};

BreadCrumb.prototype.updated = function(value) {
  const modeShowTip = value || window.modeShowTip;

  const backgroundPage = myEditor.editor.graph.backgroundPage;
  if (!backgroundPage || !modeShowTip) return;
  let width = 0;
  const i = modeShowTip.indexOf('[');
  if (modeShowTip.substr(i + 1).indexOf('[') > -1) {
    width =
      this.getTextWidt('strong', modeShowTip.substr(0, i), 12) + this.getTextWidt('span', modeShowTip.substr(i), 12);
    backgroundPage.value = `<div style="text-align: left;padding: 0 10px;line-height: 20px;"><strong style="font-weight: 700;">${modeShowTip.substr(
      0,
      i
    )}</strong><span> ${modeShowTip.substr(i)}</span></div>`;
  } else {
    width = this.getTextWidt('span', modeShowTip, 12);
    backgroundPage.value = `<div style="text-align: left;padding: 0 10px;line-height: 20px;"><span> ${modeShowTip}</span></div>`;
  }
  const styleArray = backgroundPage.style.split(';');
  const labelXIndex = styleArray.findIndex(i => i.indexOf('labelX') > -1);
  if (labelXIndex > -1 && !isNaN(width)) {
    console.log(width);
    styleArray[labelXIndex] = `labelX=${width * 1.1 + 23}`;
    backgroundPage.style = styleArray.join(';');
  }
  myEditor.editor.graph.refresh(backgroundPage)
};
